<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@	page import="kau.dao.*"%>
<%@	page import="kau.vo.*"%>
<%@	page import="java.util.ArrayList"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>



<title>회원권한관리</title>

<script type="text/javascript">
	function showPermissionList() {
		var fm = document.form;
		//alert(fm.selectedCustLevel.value);
		//location.replace('index.jsp');

		location.replace('showPermissionCust.cust?selectedCustLevel='
				+ fm.selectedCustLevel.value);
	}

	function checkSelect(selectId, formId) {
		var sValue = document.getElementById(selectId).value;
		var fId = document.getElementById(formId);

		if (sValue == 0) {
			alert("등급을 선택하세요");
			return false;
		}
		alert("등급 변경 완료 되었습니다.");
		return true;
	}
</script>

<style>
<!--
@import url("css/style.css");
-->
</style>


<style type="text/css">
#info {
	font-family: 맑은 고딕, dotum, sans-serif, bold;
	font-size: 13px
}
</style>

</head>
<body>

	<%
		ArrayList<Customer> custList = (ArrayList) request
				.getAttribute("custList");
	%>

	<div id="info">
		<br>
		<table align="left" style="margin-left: 20px">
			<tr>

				<td width="60" height="50"><img
					src="/nems/admin/images/auth.png" width="40"/></td>

				<td>
					<h4
						style="font-weight: bold; color: #005700; text-align: left; font-size: 20px;">회원등급관리</h4>
				</td>
			</tr>
		</table>
		<br><br>
		<form name='form'>


			<p align="right" style="margin-right: 25px">
				<strong>카테고리 선택 : </strong> <select name="selectedCustLevel"
					onchange="showPermissionList()">
					<option value="0">전체보기</option>
					<option value="1">관리자</option>
					<option value="2">강사</option>
					<option value="3">학생</option>
					<option value="4">권한없음</option>
				</select>
		</form>

<center>
		<table id="newspaper-a" style="width: 700px">
			<thead>
				<tr>
					<th scope="col" width="10px">No.</th>
					<th scope="col" align="center">회원ID</th>
					<th scope="col">회원이름</th>
					<th scope="col">현재등급</th>
					<th scope="col">변경등급</th>
					<th scope="col">관리</th>
				</tr>
			</thead>

			<tbody>
				<%
					for (int i = 0; i < custList.size(); i++) {
				%>
				<form class="form-horizontal" action="update_custPermission.cust"
					id="form_<%=i + 1%>">
					<input type="hidden" name="nextType" value="noPermissionCust">
					<tr align="center">
						<td><%=i + 1%></td>
						<td><input type="hidden" name="custId"
							value=<%=custList.get(i).getCustId()%>> <%=custList.get(i).getCustId()%></td>
						<td><%=custList.get(i).getCustName()%></td>
						<td><%=custList.get(i).getCustLevel()%></td>
						<td><select name="custLevel" id="select_<%=i + 1%>">

								<%
									String temp[] = new String[4];
										for (int k = 0; k < 4; k++) {
											if (k + 1 == custList.get(i).getCustLevel())
												temp[k] = "SELECTED";
											else
												temp[k] = "";
										}
								%>
								<option value="1" <%=temp[0]%>>1.관리자</option>
								<option value="2" <%=temp[1]%>>2.강사</option>
								<option value="3" <%=temp[2]%>>3.학생</option>
								<option value="4" <%=temp[3]%>>4.권한없음</option>
						</select></td>
						<td><button class="positive" style="width: 70px;"
								onclick='return checkSelect("select_<%=i + 1%>","form_<%=i + 1%>")'>
								<img src="admin/images/add.png"
									style="width: 20px; height: 20px" />변경
							</button></td>

					</tr>
				</form>
				<%
					}
				%>
			</tbody>
		</table>
</center>
		<center>
			<a href="javascript:history.go(-1)" class="css_btn_class">이전화면으로</a>
		</center>


	</div>
</body>
</html>